package com.qf.myrbac.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Component;

/**
 * 让freemark模板中的<#if shiro.hasPermission("sys:user:xxxx")>生效
 */
@Component
public class ShiroTag {
    public boolean hasPermission(String permission) {
        Subject subject = SecurityUtils.getSubject();
        return permission != null && subject.isPermitted(permission);
    }
}
